/**
 * @author jaanush
 */
dojo.require("dijit._Widget");
dojo.require("dijit._Templated");

dojo.provide("slipstream.store.Manager");
dojo.provide("slipstream.store.Summary");
dojo.declare("slipstream.store.Manager", null, {
	data: {},
	catTopic: '',
	constructor: function(){
		console.debug('manager');
		this.catTopic=dojo.subscribe("category", this, 'changeCat');
	},
	changeCat: function(arg){console.debug(arg)}
});


dojo.declare("slipstream.store.Summary", [dijit._Widget, dijit._Templated], {
	templatePath: dojo.moduleUrl("slipstream.store", "templates/Summary.html"),
	prodnum: 0,
	prodsum: 0,
	cartId: '',
	update: function(){
		//console.debug(this);
		var nodes=prodCart.getAllNodes();
		psum=0;
		pnum=0;
		dojo.forEach(nodes, function(node){
			dnode=dijit.byId(node.id);
			psum+=(dnode.quantity*dnode.price);
			pnum+=dnode.quantity;
		});
		this.prodsum=psum;
		this.prodnum=pnum;
		//this.prodsum=sum+' SEK';
		//this.domNode.firstChild.firstChild.nodeValue='Antal produkter: '+this.prodnum;
		//this.domNode.firstChild.lastChild.firstChild.nodeValue='Summa: '+this.prodsum+' SEK';
		this.domNode.firstChild.innerHTML='Antal produkter: '+this.prodnum+'<br><strong>Summa: '+dojo.currency.format((this.prodsum+95), {currency: 'SEK', fractional: false})+'</strong>';
		dojo.byId('cartSummary').innerHTML='Produkter: '+this.prodnum+'<br />Frakt: SEK 95<br /><strong>Summa: '+dojo.currency.format((this.prodsum+95), {currency: 'SEK', fractional: false})+'</strong>';
		//console.debug(this);
	}
});